package net.daum.webtoon.android.dto;

import java.util.Iterator;

import org.json.JSONException;
import org.json.JSONObject;

public class DTO_Episode extends JSonDataObjectBase {

	public String id;
	public String episode;
	public String title;
	public String shortTitle;
	public ThumbnailImage thumbnailImage;

	public String episodeImage;
	public String encryptUseYn;
	public String serviceStatus;
	public String articleId;
	public String commentUseYn;
	public String dateCreated;
	public String webtoon;
	public String serviceType;
	public String price;
	public String padtoonImage;
	public String payWebtoonEpisode;
	public VoteTarget voteTarget;

	public DTO_Episode(JSONObject aJsonObject) {
		Iterator<Object> iterator = aJsonObject.keys();

		while (iterator.hasNext()) {
			Object obj = iterator.next();
			if (obj.toString().equalsIgnoreCase("voteTarget")) {
				try {
					this.voteTarget = new VoteTarget(aJsonObject.getJSONObject("voteTarget"));
				} catch (JSONException e) {
					if (isDebug)
						e.printStackTrace();
				}
			} else if (obj.toString().equalsIgnoreCase("thumbnailImage")) {
				try {
					this.thumbnailImage = new ThumbnailImage(aJsonObject.getJSONObject("thumbnailImage"));
				} catch (JSONException e) {
					if (isDebug)
						e.printStackTrace();
				}
			} else {
				setMemberFiled(this, aJsonObject, obj.toString());
			}
		}
		printMembers();

	}

	class ThumbnailImage extends JSonDataObjectBase {
		public String id;
		public String url;
		public String name;
		public String size;
		public String width;
		public String height;
		public String mediaType;

		public ThumbnailImage(JSONObject aJsonObject) {
			// TODO Auto-generated constructor stub
			init(aJsonObject);
			printMembers();
		}
	}

	class VoteTarget extends JSonDataObjectBase {
		public String id;
		public String voteServiceId;
		public String serviceTargetId;
		public String voteCount;
		public String ranking;
		public String diff;
		public String voteTotalScore;
		public String dateCreated;
		public String lastUpdated;

		public VoteTarget(JSONObject aJsonObject) {
			// TODO Auto-generated constructor stub
			init(aJsonObject);

			printMembers();
			insertObjToDB();
		}
	}
}
